home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c,gnu.gcc.help
- Subject: Re: Casting unsigned short as unsigned int -> Bus error
- Date: Fri, 05 Jan 96 21:59:46 GMT
- Organization: none
- Message-ID: <820879186snz@genesis.demon.co.uk>
- References: <simmons.820857453@rzdspc1>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <simmons.820857453@rzdspc1>
- simmons@rzdspc1.informatik.uni-hamburg.de "Geoffrey Simmons" writes:
-
- >I have a pointer to a struct with a member declared as unsigned short:
- >
- > typedef struct {
- > ...
- > unsigned short myshort;
- > ...
- > } RecType;
- >
- > RecType *MyRec;
- >
- >Now when I try to dereference that member, casting it to (unsigned int),
- >I get a bus error:
- >
- > unsigned int myint;
- >
- > myint = (unsigned int) MyRec->myshort; /* Bus error! */
- >
- >I'm using GCC 2.7.2 on a SparcStation running SunOS 4.1.4. I've made sure
- >that the pointer points to valid data.
-
- If that is so then the code is perfectly valid (and the cast is redundant) -
- your problem is caused somewhere else. Post a minimal compilable program that
- demonstrates the problem.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-